<template>
  <div class="home">
    <div style="width: 100%">
      <h2 style="text-align: center">我的投标</h2>
      <el-table :data="list.data" style="width: 100%">
        <el-table-column align="center" label="序号" type="index" width="100">
        </el-table-column>
        <el-table-column prop="procurementMark.title" label="标的发布名称">
        </el-table-column>
        <el-table-column prop="procurementMark.bidType" label="标状态">
          <template slot-scope="scope">
            {{ bidType(scope.row.procurementMark.bidType) }}
          </template>
        </el-table-column>
        <el-table-column
          width="150"
          prop="procurementMark.endTime"
          label="投标结束时间"
        >
        </el-table-column>
        <el-table-column width="100" prop="title" label="操作">
          <template slot-scope="scope">
            <el-button
              :disabled="scope.row.procurementMark.bidType == 2"
              @click="submit(scope.row)"
              type="text"
              >提交资料</el-button
            >
          </template>
        </el-table-column>
      </el-table>
      <el-pagination
        background
        layout="prev, pager, next"
        :total="this.total"
        :page-size="pageSize"
        :current-page.sync="currentPage"
        @current-change="getList"
      ></el-pagination>
    </div>
  </div>
</template>
<script>
import { getHaveBidList } from "@/api/procurement/HaveBid";
export default {
  data() {
    return {
      dialogVisible: false,
      currentPage: 1,
      list: [],
      userRes: {},
      pageSize: 5,
      total: 0,
    };
  },
  mounted() {
    this.userRes = this.$store.state.user.userRes;
    this.getList();
  },
  methods: {
    bidType(type) {
      if (type == 0) {
        return "资料待提交";
      } else if (type == 1) {
        return "已过期";
      } else if (type == 2) {
        return "资质审核";
      } else if (type == 3) {
        return "待开标";
      } else if (type == 4) {
        return "开标结果";
      } else if (type == 5) {
        return "未报名";
      }
    },
    handleClose(done) {
      this.$confirm("确认关闭？")
        .then((_) => {
          done();
        })
        .catch((_) => {});
    },
    // 获取列表
    getList() {
      getHaveBidList({
        pageIndex: this.currentPage,
        pageSize: this.pageSize,
        userId: this.userRes.userId,
      }).then((res) => {
        console.log(res);
        this.list = res;
        this.total = res.total;
      });
    },
    // 提交资料
    submit(item) {
      this.$router.push({
        name: "targetSubmit",
        query: {
          id: item.id,
        },
      });
    },
  },
};
</script>
<style scoped>
.el-pagination {
  float: right;
  margin-top: 20px;
}
</style>
